#ifndef ALTGRAPHICSZOOMWIDGET_H
#define ALTGRAPHICSZOOMWIDGET_H

#include <QWidget>

class QSpinBox;
class QGraphicsView;
class QSlider;

namespace Alt {
     /*! Provides a zoom control for QGraphicsView widgets. */
     class GraphicsZoomWidget : public QWidget {
          Q_OBJECT
     public:
          /*! The default maximum zoom level when none is set. */
          static const int DefaultMaxZoomLevel;

          /*! Default constructor.
               \param view The graphics view to zoom.
               \param parent The parent object. */
          GraphicsZoomWidget(QGraphicsView* view = 0, QWidget* parent = 0);

          /*! The maximum allowed zoom level, as a percentage. */
          int maxZoomLevel() const;

          /*! Set the maximum allowed zoom level.
               \param maxZoom The new maximum zoom level, as a percentage. The maximum zoom must be greater than 100. */
          void setMaxZoomLevel(int maxZoom);

          /*! Sets the graphics view to zoom.
               \param view The new graphics view. */
          void setView(QGraphicsView* view);

          /*! The graphics view being zoomed. */
          QGraphicsView* view() const;

          /*! The current zoom level. */
          int zoomLevel() const;

     public slots:
          /*! Sets the zoom level.
               \param zoomLevel The zoom level, as a percentage. Passing 0 is equivalent to zoomToFit().
                    Negative values are ignored. */
          void setZoomLevel(int zoomLevel);

          /*! Zooms to fit the contents of the scene rectangle. */
          void zoomToFit();

     signals:
          /*! Emitted when the zoom level is changed.
               \param newZoomLevel The new zoom level, as a percentage. */
          void zoomLevelChanged(int newZoomLevel);

     private:
          /*! Initializes the widget. */
          void init();

          /*! The view being zoomed. */
          QGraphicsView* m_view;

          /*! Spin box controlling zoom level. */
          QSpinBox* m_zoomSpin;

          /*! Slider controlling zoom level. */
          QSlider* m_zoomSlider;

          /*! The current zoom level. as a percentage. */
          int m_zoomLevel;

          /*! The maximum allowed zoom level, as a percentage. */
          int m_maxZoom;
     };
}

#endif
